package models

import (
	"fmt"

	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

var DB *gorm.DB

func InitDB(mu, mp, md string) {
	var err error

	//	DB, err = gorm.Open("mysql", mysql_user+":"+mysql_pwd+"@/"+mysql_database+"?charset=utf8")
	cnt := fmt.Sprintf("%s:%s@/%s?charset=utf8", mu, mp, md)
	DB, err = gorm.Open("mysql", cnt)
	if err != nil {
		panic(err)
	}
	DB.DB().SetMaxIdleConns(50)
	DB.DB().SetMaxOpenConns(50)
}
